export function formatDate (date, fmt) {
  if (!date) { return "" }
  if (typeof date == "string") {
    date = parseInt(date)
  }
  date=date*1000;
  date=new Date(date);
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  }
  let o = {
    'M+': date.getMonth() + 1,
    'd+': date.getDate(),
    'h+': date.getHours(),
    'm+': date.getMinutes(),
    's+': date.getSeconds()
  }
  for (let k in o) {
  if (new RegExp(`(${k})`).test(fmt)) {
      let str = o[k] + ''
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str))
    }
  }
  return fmt
}
function padLeftZero(str){
    return ('00'+str).substr(str.length);
}

export function changeorderstate(v){
  switch(v){
    case 0:
      return "待付款";
      break;
    case 1:
      return "拼团中";
      break;
    case 2:
      return "待发货";
      break;
    case 3:
      return "待收货";
      break;
    case 4:
      return "已完成";
      break;
    case 5:
      return "已取消";
      break;
    case 6:
      return "未成团";
      break;
    case 7:
      return "已退款";
      break;
    
  }
}


export function paytype(v){
  switch(v){
    case 1:
      return "微信支付";
      break;
    case 2:
      return "支付宝支付";
      break;
    case 4:
      return "预存款支付";
      break;
    case 5:
      return "货到付款";
      break;
    case 6:
      return "现金";
      break;
    case 7:
      return "第三方支付";
      break;
  }
}

export function receivedRecordtype(v){
  switch(v){
    case 0:
      return "系统确认";
      break;
    case 0:
      return "用户确认";
      break;
  }
}